package org.example.tms.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.tms.config.AjaxResult;
import org.example.tms.utils.AliOSSUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
//@Deprecated   //无法处理依赖注入问题(@Autowired,@Component)
@Slf4j
@RestController
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file ) throws IOException {

        String url = aliOSSUtils.upload(file);

        return AjaxResult.success(url);

    }
}
